<?php

include './functions.php';
include './Db.php';

$data = $_POST;

$db = new Db('user');

$db->where('username="'.$data['username'].'" and password="'.md5($data['password']).'"');

$res = $db->select();


if(!$res){
	exit(json_encode(['error'=>1,'msg'=>'用户或者密码不正确']));
}else{

	$_SESSION['username'] = $data['username'];

	$_SESSION['user_id'] = $res[0]['user_id'];

	exit(json_encode(['error'=>0,'msg'=>'登录成功']));
}




